/****************************************************************************

 Copyright (C) 2002-2011 Gilles Debunne. All rights reserved.

 This file is part of the QGLViewer library version 2.3.17.

 http://www.libqglviewer.com - contact@libqglviewer.com

 This file may be used under the terms of the GNU General Public License
 versions 2.0 or 3.0 as published by the Free Software Foundation and
 appearing in the LICENSE file included in the packaging of this file.
 In addition, as a special exception, Gilles Debunne gives you certain
 additional rights, described in the file GPL_EXCEPTION in this package.

 libQGLViewer uses dual licensing. Commercial/proprietary software must
 purchase a libQGLViewer Commercial License.

 This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
 WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.

*****************************************************************************/

#include <QGLViewer/qglviewer.h>
#include "typedefs.h"
#include "vector3.h"
#include "quaternion.h"

class StandardCamera;
class Display;
class Scene;

class Viewer : public QGLViewer
{
Q_OBJECT

    Scene *scene;
    Display * display;

    QTimer *simulationTimer;

    bool drawProfile;



public :
  Viewer(StandardCamera* camera);

  virtual ~Viewer()
  {
      saveStateToFile();
      delete(scene);
      delete(display);
      delete(simulationTimer);
  }

  void setPlay();
  void stop();
  void saveScene();
  void loadScene();
  void deleteScene();
  void setSolid();
  void setWire();
  void addSphere(Math::Real radius);
  void addBox(Math::Vector3 &sizeBox);
  void addMesh(QString filename);
  void setSelectedBBox(int);
  void setSelectedColor(QColor cd);
  void focusSelected();
  void translateSelected(Math::Vector3 &t);
  void rotateSelected(Math::Real &angle, Math::Vector3 &t);
  void setGravity(Math::Real &g);
  void setSelectedStatic(int &s);
  void selectedChanged();

public :
 Q_SIGNALS :
  void cameraChanged();
  void gravityChanged(QString);
  void timestepChanged(QString);
  void selectedPositionChanged(Math::Vector3 v);


protected :
  virtual void draw();
  virtual void drawWithNames();
  virtual void postSelection(const QPoint& point);
  virtual void init();
  virtual QString helpString() const;
  virtual void keyPressEvent(QKeyEvent *e);
  virtual void 	wheelEvent (QWheelEvent *e);
  virtual void animate();

private :
  qglviewer::Vec orig, dir, selectedPoint;
  void showMessage();
};
